// 元素类型定义
export const ElementTypes = {
  TEXT: 'text',
  IMAGE: 'image',
  SHAPE: 'shape',
  GROUP: 'group',
  STICKER: 'sticker',
  ILLUSTRATION: 'illustration',
  TEMPLATE: 'template'
} as const;

export type ElementType = typeof ElementTypes[keyof typeof ElementTypes];

// 基础元素接口
export interface Element {
  id: string;
  type: ElementType;
  fabricObject: fabric.Object;
  isSelected: boolean;
  isLocked: boolean;
  position: { x: number; y: number };
  size: { width: number; height: number };
  rotation: number;
  opacity: number;
  isVisible: boolean;
  zIndex: number;
  [key: string]: any;
}

// 事件类型定义
export const EventTypes = {
  // 元素相关事件
  ELEMENT_SELECTED: 'element:selected',
  ELEMENT_DESELECTED: 'element:deselected',
  ELEMENT_ADDED: 'element:added',
  ELEMENT_REMOVED: 'element:removed',
  ELEMENT_MODIFIED: 'element:modified',
  ELEMENT_LOCKED: 'element:locked',
  ELEMENT_UNLOCKED: 'element:unlocked',
  
  // 工具栏相关事件
  TOOLBAR_SHOW: 'toolbar:show',
  TOOLBAR_HIDE: 'toolbar:hide',
  TOOLBAR_ACTION: 'toolbar:action',
  
  // 画布相关事件
  CANVAS_ZOOMED: 'canvas:zoomed',
  CANVAS_PANNED: 'canvas:panned',
  CANVAS_RESIZED: 'canvas:resized',
  
  // 历史记录相关事件
  HISTORY_UNDO: 'history:undo',
  HISTORY_REDO: 'history:redo',
  HISTORY_CHANGED: 'history:changed',
  
  // 模式切换相关事件
  MODE_CHANGED: 'mode:changed',
  
  // 错误相关事件
  ERROR_OCCURRED: 'error:occurred'
} as const;

export type EventType = typeof EventTypes[keyof typeof EventTypes];

// 事件回调类型
export type EventCallback = (payload?: any) => void;

// 操作类型定义
export type ActionType = 
  | 'element-add'
  | 'element-remove'
  | 'element-modify'
  | 'element-move'
  | 'element-resize'
  | 'element-rotate'
  | 'element-style-change'
  | 'group-create'
  | 'group-ungroup'
  | 'layer-reorder';

// 历史记录项接口
export interface HistoryItem {
  id: string;
  type: ActionType;
  timestamp: number;
  data: {
    before: any;
    after: any;
  };
  description: string;
}